Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Update key vault data sdk to T2, mangement SDK to latest.#3

Merged
jongio merged 10 commits into
Azure-Samples:masterfrom
wantedfast:Dev-updateSDK
Nov 18, 2020
Merged

Update key vault data sdk to T2, mangement SDK to latest.#3
jongio merged 10 commits into
Azure-Samples:masterfrom
wantedfast:Dev-updateSDK

Conversation

@wantedfast
Copy link
Copy Markdown
Contributor

Purpose

Update key vault data sdk to T2, key vault management SDK to latest.

@wantedfast wantedfast marked this pull request as ready for review May 18, 2020 07:33
…" to the value read from app.config. AzureEnvironment.AzureGlobalCloud remains as default.
Comment thread ClientContext.cs
/// <summary>
/// Generic ADAL Authentication callback
/// </summary>
public static async Task<string> AcquireTokenAsync(string authority, string resource, string scope)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To track 2, there is new SecretClient instead of KeyVaultClient to use. this AcquireTokenAsync() is used to create KeyVaultClient in KeyvaultSampleBase delegate. So this is decided to remove

Comment thread KeyVaultSampleBase.cs Outdated
// instantiate the data client
DataClient = new KeyVaultClient(ClientContext.AcquireTokenAsync);
//Get current Authority Host for Azure
TokenCredentialOptions options = new TokenCredentialOptions();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we did not set options.AuthorityHost, ClientSecretCredential will always set as default "AzureGlobalCloud"

@jongio
Copy link
Copy Markdown
Member

jongio commented Aug 8, 2020

Please try with the new preview mgmt libs: https://www.nuget.org/packages/Azure.ResourceManager.KeyVault/1.0.0-preview.1

@FrankieTF
Copy link
Copy Markdown

FrankieTF commented Sep 17, 2020

Service: KeyVault; SDK: key vault mgmt sdk and azure key vault data sdk(t1)
Updates as belows:

  • Update key vault mgmt sdk and data sdk to track2.
  • Simplify ClientContext.
  • Update README.

@jongio
Copy link
Copy Markdown
Member

jongio commented Sep 22, 2020

@heaths - Can you please review?
@nickzhums - Do we want to update to the new mgmt libs?

Copy link
Copy Markdown

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a few changes, but otherwise LGTM.

Comment thread ClientContext.cs
@@ -13,8 +10,6 @@ namespace AzureKeyVaultRecoverySamples
/// </summary>
public sealed class ClientContext
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of this class is really used anymore. Perhaps just replace it with the DefaultAzureCredential directly in the client like we normally do in samples. I worry the unnecessary complexity here will just make people copy the design when simply passing a DefaultAzureCredential is so much simpler.

Comment thread KeyVaultEntityRecoverySamples.cs Outdated

// wait for purge complete
Console.Write("Waiting for Purging complete...");
Thread.Sleep(60 * 1000);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While sleeping for a bit is a good idea (and there's nothing more we can do anyway), you should actually have a limited retry loop. Purging can take a while, and will vary (it may be a scheduled task in the backend).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heaths , i am not sure how to implement this limited retry loop. As i think there's nothing more we can do here.

Comment thread KeyVaultRecoverySamples.cs Outdated

Console.Write("Retrieving newly created vault...");
var retrievedVault = await sample.ManagementClient.Vaults.GetAsync(rgName, vaultName).ConfigureAwait(false);
var retrievedVault = (await sample.ManagementClient.Vaults.GetAsync(rgName, vaultName).ConfigureAwait(false)).Value;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the sample above, I'd stick with Response<T> here and use its Value property only when needed.

Comment thread KeyVaultSampleBase.cs Outdated
/// </summary>
protected ClientContext context;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: git doesn't like whitespace-only lines.

Comment thread README.md Outdated
- dotnet-core
description: "This repo contains sample code demonstrating the backup/restore and recoverable deletion functionality of Azure Key Vault using the Azure .NET SDK."
urlFragment: net-sdk-samples
urlFragment: key-vault-dotnet-recovery
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in broken links. urlFragment should neve be changed. It's unfortunate it was generic before, but should remain the same. Just be more specific going forward.

Comment thread README.md Outdated
To complete this tutorial:

The recoverable deletion functionality is also referred to as 'soft delete'; consequently, a permanent, irrecoverable deletion is referred to as 'purge'.
* Install .NET Core 2.0 version for [Linux] or [Windows]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0 is out of support. 2.1 is LTS, but so is 3.1. We should at least recommend an LTS.

Comment thread README.md Outdated
### Create an App registration using the Azure Portal

## Getting Started
* Go to the [Azure Portal] and log in using your Azure account.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps should be numbered. Alternatives should be bulleted.

Comment thread README.md Outdated
[free account]: https://azure.microsoft.com/free/?WT.mc_id=A261C142F
[Azure Portal]: https://portal.azure.com
[Recovery scenario samples for Azure Key Vault using the Azure Node SDK]: https://docs.microsoft.com/en-us/samples/azure-samples/key-vault-node-recovery/key-vault-node-recovery/
[Azure Key Vault documentation]: https://docs.microsoft.com/en-us/azure/key-vault/general/basic-concepts
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URLs should not include the locale. In VSCode, install the Microsoft Docs Authoring Pack for rules you should follow when writing markdowns (it would catch this issue).

I see a couple URLs like that. This always goes to the specified language/locale, while leaving it out uses the browsers' preferred languages (better for non-en-US readers).

@heaths
Copy link
Copy Markdown

heaths commented Sep 22, 2020

Happy to review, but @jongio or @wantedfast, could I get a review on my sample at Azure/azure-sdk-for-net#15123? It's been sitting there for quite a while. The brunt of it was previously reviewed by Alex at its original home (https://github.com/heaths/KeyVaultProxy), but I had to make a few changes to build / run in our repo, per @weshaggard's desire to host samples in a single place going forward.

@nickzhums
Copy link
Copy Markdown

@wantedfast @heaths just FYI - .NET SDK team is designing a new set of APIs that will be previewed at the end of year. There can be some upcoming changes in this key vault code sample. The Track 2 .NET SDK won't be GA-ed for a while, so if we expect the customer to see a stable version in a code sample, probably better to stay on Track 1, otherwise, feel free to update to Track 2.
cc @jongio

@heaths
Copy link
Copy Markdown

heaths commented Sep 24, 2020

The preview functionality coming out later is in addition to what is here. We're aren't changing anything that is demo'd here. Seems better to show customers more track 2 code since we are deprecating track 1.

@heaths
Copy link
Copy Markdown

heaths commented Oct 9, 2020

If possible, please avoid force-pushing until you're ready to merge (for example, if rebasing on master to pick up recent changes). I can't tell what's changed so I will have to re-review the entire PR again.

Comment thread KeyVaultEntityRecoverySamples.cs Outdated
catch (CloudException ce)
{
Console.WriteLine("Unexpected ARM exception encountered: {0}", ce.Message);
Console.WriteLine("Unexpected KeyVault exception encountered: {0}", ex.Message);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the product name is "Key Vault" (with a space). We should use that in customer-facing messages / docs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment thread KeyVaultSampleBase.cs Outdated
/// </summary>
protected ClientContext context;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: extraneous whitespace.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment thread README.md
To complete this tutorial:

The recoverable deletion functionality is also referred to as 'soft delete'; consequently, a permanent, irrecoverable deletion is referred to as 'purge'.
* Install .NET Core 3.1 version for [Linux] or [Windows]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use - consistently throughout the markdown (you use mainly this below).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U mentioned steps need numbered, alternative should be bulleted. I think this is much better than mix them.
Do you still think we should keep consistency or changing below with numbered steps?
Like what i have done now.

@FrankieTF
Copy link
Copy Markdown

Sorry for let you review again, this force-pushing is because this PR needs step back. I will be more careful with force-pushing next time.

@jongio jongio merged commit 589d10a into Azure-Samples:master Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants